

output "instance_id" {
  description = "ECS实例ID列表"
  value       = values(alicloud_instance.this)[*].id
}

output "public_ip" {
  description = "ECS公网IP列表（用于SSH连接）"
  value       = [for instance in values(alicloud_instance.this) : instance.public_ip]
  sensitive   = true
}

output "private_ip" {
  description = "ECS内网IP列表"
  value       = [for instance in values(alicloud_instance.this) : instance.private_ip]
  sensitive   = true
}

output "connection_info" {
  description = "ECS连接信息汇总"
  value = {
    public_ips  = [for instance in values(alicloud_instance.this) : instance.public_ip],
    private_ips = [for instance in values(alicloud_instance.this) : instance.private_ip],
    instance_ids = values(alicloud_instance.this)[*].id
  }
}

output "web_server_public_ip" {
  value = alicloud_instance.this["web_server"].public_ip
  description = "web-01服务器公网IP"
}